package com.example.myapplication.navigation;

import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.fragment.NavHostFragment;

import com.example.myapplication.R;
import com.example.myapplication.databinding.ActivityFragmentEnterBinding;
import com.example.myapplication.databinding.ActivityRecoverFragmentEnterBinding;
import com.example.myapplication.navigation.fragment_recover.ProductMainFragmentLife;
import com.example.myapplication.utils.NameCreator;

import java.util.List;


/**
 * Created by xiaolong on 2021/12/6 9:18 下午
 * email：xinxiaolong123@foxmail.com
 */
public class RecoverFragmentActivity extends AppCompatActivity {

    ActivityRecoverFragmentEnterBinding binding;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        binding=ActivityRecoverFragmentEnterBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
    }


    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if(keyCode==KeyEvent.KEYCODE_BACK){
            Log.e("fragment_lifecycle","###################################点击了返回键###################################");
        }
        return super.onKeyDown(keyCode, event);
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        NameCreator.getInstance().clear();
    }

    @Override
    public void onBackPressed() {
        Fragment mMainNavFragment = getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);
        //获取指定的fragment
        Fragment fragment = mMainNavFragment.getChildFragmentManager().getPrimaryNavigationFragment();
        super.onBackPressed();
    }
}
